/*
 * @Author: herw
 * @Date: 2020-09-22 10:48:21
 * @Last Modified by: herw
 * @Last Modified time: 2020-09-23 09:40:17
 */

export function formatDictText(dicts, values) {
  if (!(Array.isArray(dicts) && dicts.length > 0)) {
    return values
  }
  if (!values) {
    return ''
  }
  const valueArr = values.split(',')
  const contentArr = []
  dicts.forEach(dict => {
    for (let i = 0; i < valueArr.length; i++) {
      if (valueArr[i] === dict.value) {
        contentArr.push(dict.label)
        break
      }
    }
  })
  return contentArr.toString()
}

export default { formatDictText }
